package com.zuxia.handler;


import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.Instant;
import java.util.Date;

/**
 * @author Administrator
 * @version 1.0
 * @description: TODO
 * @date 2024/10/30 11:42
 */

@Component
public class CommonMetaObjectHandler implements MetaObjectHandler {
    private Date time = new Date(Instant.now().toEpochMilli());

    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("gmtCreate", time, metaObject);
        this.setFieldValByName("gmtModified", time, metaObject);
        this.setFieldValByName("joinDate", time, metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("gmtModified", time, metaObject);
    }
}
